package com.zhouheng.springbootdesignpattern.singletonpattern;

/**
 * 懒汉式单例 演示
 *
 * @author 周恒
 * @date 20190315 10:56:18
 * @since v1.0
 */
public class LazyMan {

    private static LazyMan slacker;

    private LazyMan() {

    }

    public static synchronized LazyMan getInstance() {
        if (null == slacker) {
            slacker = new LazyMan();
            // 1开辟空间 2初始化对象信息 3返回对象的地址给引用
        }
        return slacker;
    }

}
